﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using PSI.Services;
using System.Data;
using System.Text;

namespace PSI.Models
{

    public class KnowledgeType:PSIBaseService
    {
        /// <summary>
        /// ID
        /// </summary>
        public Guid id { get; set; }
        /// <summary>
        /// 类别名称
        /// </summary>
        public string name { get; set; }

        /// <summary>
        /// 主题集合
        /// </summary>
        public List<KnowledgeTheme> KthemeItem
        {
            get {
                if (this.id != null)
                {
                    var cc = new List<KnowledgeTheme>();
                    var str = new StringBuilder("select * from KnowledgeTheme where KTypeID=@id");
                    var p=CreateDbParameters();
                    p.AddWithValue("id", this.id.ToString());
                    Query(str.ToString(), p, ready =>
                    {
                        cc.Add(new KnowledgeTheme()
                        {
                            id=ready.GetGuid(ready.GetOrdinal("id")),
                            KTypeID = ready.GetGuid(ready.GetOrdinal("KtypeID")),
                            title = ready.GetString(ready.GetOrdinal("Title")),
                            Contents = ready.GetString(ready.GetOrdinal("Contents")),
                            FileOne = ready.GetString(ready.GetOrdinal("File_one")),
                            FileTwo = ready.GetString(ready.GetOrdinal("File_two")),
                            CreatPerson = ready.GetString(ready.GetOrdinal("CreatPrent")),
                            CreatTime = ready.GetDateTime(ready.GetOrdinal("CreatTime")),  
                        });

                    });
                    return cc;
                }
                else
                {
                    return null;
                }
            }
        }
    }

    public class KnowledgeTheme:PSIBaseService
    {
        /// <summary>
        /// ID
        /// </summary>
        public Guid id { get; set; }

        /// <summary>
        /// 类别ID
        /// </summary>
        public Guid KTypeID { get; set; }

        /// <summary>
        /// 标题
        /// </summary>
        public string title { get; set; }

        /// <summary>
        /// 内容
        /// </summary>
        public string Contents { get; set; }

        /// <summary>
        /// 附件1
        /// </summary>
        public string FileOne { get; set; }

        /// <summary>
        /// 附件2
        /// </summary>
        public string FileTwo { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreatTime { get; set; }
        
        /// <summary>
        /// 创建人
        /// </summary>
        public string CreatPerson { get; set; }

        /// <summary>
        /// 用户回复集合
        /// </summary>
        //public List<KnowledgeUserReply> KreplyItem
        //{

        //    get {
        //        if (this.id != null||this.id!=Guid.Empty)
        //        {
        //            var cc = new List<KnowledgeUserReply>();
        //            var str = new StringBuilder("select * from KnowledgeUserReply where KthemeID=@id");
        //            var p = CreateDbParameters();
        //            p.AddWithValue("id", this.id.ToString());
        //            Query(str.ToString(), p, ready =>
        //            {
        //                cc.Add(new KnowledgeUserReply()
        //                {
        //                    id = ready.GetGuid(ready.GetOrdinal("id")),
        //                    KthemeID = ready.GetGuid(ready.GetOrdinal("KthemeID")),
        //                    Contents = ready.GetString(ready.GetOrdinal("Contents")),
        //                    CreatPerson = ready.GetString(ready.GetOrdinal("CreatTime")),
        //                    CreatTime = ready.GetDateTime(ready.GetOrdinal("CreatPrent"))
        //                });

        //            });
        //            return cc;
        //        }
        //        else
        //        {
        //            return null;
        //        }
            
        //    }
       // }
    }

    public class KnowledgeUserReply
    {
        /// <summary>
        /// ID
        /// </summary>
        public Guid id { get; set; }

        /// <summary>
        /// 帖子ID
        /// </summary>
        public Guid KthemeID { get; set; }
        /// <summary>
        /// 内容
        /// </summary>
        public string Contents { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreatTime { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        public string CreatPerson { get; set; }
    }


   

}